package consume.headers;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author : xiaohong
 * @date : 2021/4/11 15:35
 */


@Component
public class Headers1Consumer {

    @RabbitListener(queues = {"headers1"})
    public void receive1(Channel channel, String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
        System.out.println("headers1接收到消息：  "+message);
        channel.basicAck(tag,true);
    }

    @RabbitListener(queues = {"headers2"})
    public void receive2(Channel channel, String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
        System.out.println("headers2接收到消息：  "+message);
        channel.basicAck(tag,true);
    }

    @RabbitListener(queues = {"headers3"})
    public void receive3(Channel channel, String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
        System.out.println("headers3接收到消息：  "+message);
        channel.basicAck(tag,true);
    }

}
